﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Abhar.web.src;

namespace Abhar.web.Controls
{
    public partial class NewsBox : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public int NewsId
        {
            set
            {
                this.ViewState["NewsId"] = value;
                LoadNews(value);
            }
            get
            {
                var newsId = this.ViewState["NewsId"];
                if (newsId == null)
                    return 0;
                return (int) newsId;
            }
        }

        private void LoadNews(int value)
        {
            var news = DatabaseContext.Current.News.GetById(value);
            this.uxNewsImage.ImageUrl = news.ImgUrl;
            if (this.Page.GetCurrentLanguage() == Language.English)
            {
                this.uxNewsHeader.Text = news.TitleEn;
            }
            else
                this.uxNewsHeader.Text = news.TitleAr;
        }
    }
}